//package com.ali.config;
//
//import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
//import org.springframework.boot.actuate.context.ShutdownEndpoint;
//import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//
///**
// * 执行器安全配置
// * @author nning_l@163.com
// * @date 2020年4月13日
// */
//@Configuration
//@EnableWebSecurity
//public class ActuatorSecurityConfig extends WebSecurityConfigurerAdapter {
//
//	@Override
//	protected void configure(HttpSecurity http) throws Exception {
//		/**
//		 * 限制 '/shutdown'端点的访问，只允许ADMIN访问
//		 * 允许外部访问其他的端点
//		 * 允许外部访问静态资源
//		 * 允许外部访问 '/'
//		 * 其他的访问需要被校验
//		 */
//		http.authorizeRequests()
//		.requestMatchers(EndpointRequest.to(ShutdownEndpoint.class))
//		.hasRole("ADMIN")
//		.requestMatchers(EndpointRequest.toAnyEndpoint())
//		.permitAll()
//		.requestMatchers(PathRequest.toStaticResources().atCommonLocations())
//		.permitAll()
//		.antMatchers("/")
//		.permitAll()
//		.antMatchers("/**")
//		.authenticated()
//		.and()
//		.httpBasic();
//		/**
//		 * 限制所有端点的访问，只允许ADMIN访问
//		 * 允许外部访问静态资源
//		 * 允许外部访问 '/'
//		 * 其他的访问需要被校验
//		 */
////		http.authorizeRequests()
////		.requestMatchers(EndpointRequest.toAnyEndpoint())
////		.hasRole("ADMIN")
////		.requestMatchers(PathRequest.toStaticResources().atCommonLocations())
////		.permitAll()
////		.antMatchers("/")
////		.permitAll()
////		.antMatchers("/**")
////		.authenticated()
////		.and()
////		.httpBasic();
//	}
//
//	@Override
//	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//		auth.inMemoryAuthentication()
//		.passwordEncoder(new BCryptPasswordEncoder())
//		.withUser("admin")
//		.password(new BCryptPasswordEncoder().encode("admin"))
//		.roles("USER")
//		.and()
//		.withUser("root")
//		.password(new BCryptPasswordEncoder().encode("root"))
//		.roles("USER", "ADMIN");
//	}
//
//}
